<?php
// 应用公共文件

if (!function_exists('systemConfigMore'))
{
    /**
     * 获取系统配置值
     * @param array $formNames
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    function systemConfigMore(array $formNames): array
    {
        $res = \app\admin\model\system\SystemConfig::getValuesByFormNames($formNames);
        $data = [];
        foreach ($res as $k=>$v) $data[$v['form_name']] = $v['value'];
        return $data;
    }
}

if (!function_exists('paramToArray'))
{
    /**
     * 参数分割成数组
     * @param string $param
     * @param string $delimiter
     * @return array
     */
    function paramToArray(string $param, string $delimiter = "&"): array
    {
        $arr = [];
        foreach (explode($delimiter,$param) as $value)
        {
            $tmp = explode("=",$value);
            $arr[$tmp[0]] = $tmp[1];
        }
        return $arr;
    }
}

if (!function_exists('getFileType'))
{
    /**
     * 获取文件类型
     * @param string $mime
     * @return string
     */
    function getFileType(string $mime): string
    {
        if (stristr($mime,'image')) return 'image';
        elseif (stristr($mime,'video')) return 'video';
        elseif (stristr($mime,'audio')) return 'audio';
    }
}

//基本配置
if (!function_exists("getConfig"))
{
    /**
     * 获取配置
     * @param string $mime
     * @return string
     */
    function getConfig ()
    {
        $config = [
            'marriage' => [              //婚姻状况
                1 => "已婚",
                2 => '未婚',
                3 => '丧偶',
                4 => '离异',
                5 => '再婚',
                6 => '未知'
            ],
            'education' => [            //学历选择
                1 => '硕士',
                2 => '本科',
                3 => '专科',
                4 => '博士及以上',
                5 => '高中/中专',
                6 => '初中',
                7 => '初中以下'
            ],
            'income' => [               //月薪
                1 => '3500 以下',
                2 => '3500-6000',
                3 => '6000-10000',
                4 => '10000-20000',
                5 => '20000 以上'
            ],
            'occupation' => [           //职业类型
                1 => '一般职工',
                2 => '工厂',
                3 => '农牧业',
                4 => '渔业',
                5 => '木材、森林业',
                6 => '矿业、采石业',
                7 => '交通运输业',
                8 => '旅游业',
                9 => '餐饮业',
                10 => '制造业',
                11 => '医院、诊所',
                12 => '娱乐业',
                13 => '教育业',
                14 => '金融业',
                15 => '邮政',
                16 => '零售',
                17 => '服务业',
                18 => '家庭主妇',
                19 => '保姆、家庭护理',
                20 => '治安人员',
                21 => '体育',
                22 => '资讯',
                23 => '个体商贩',
                24 => '国家机关、党群组织、企业负责人',
                25 => '专业技术人员',
                26 => '行政机构、企事业单位管理人员',
                27 => '保安/防损',
                28 => '军人',
                29 => '建筑工程业'
            ],
            "borrowing" => [            //借贷理由
                1 => '购买原材料',
                2 => '进货',
                3 => '购买设备',
                4 => '购买家具或家电',
                5 => '学习',
                6 => '个人或家庭消费',
                7 => '资金周转',
                8 => '装修',
                9 => '旅游',
                10 => '婚庆',
                11 => '健康医疗',
                12 => '其他'
            ],
            'industry'=> [          //行业
                1 => '生产、加工、制造业',
                2 => '农、林、牧、渔业',
                3 => '水利、环境和公共设施管理业',
                4 => '电、热、燃气及水供应业',
                5 => '文化、体育和娱乐业',
                6 => '卫生、社会保障和社会福利业',
                7 => '批发和零售业',
                8 => '科学研究和技术服务业',
                9 => '建筑业',
                10 => '住宿和餐饮业',
                11 => '信息传输和软件服务业',
                12 => '居民服务和其他服务业',
                13 => '教育业',
                14 => '交通运输、仓储和邮政业',
                15 => '采矿业',
                16 => '金融业',
                17 => '房地产业',
                18 => '公共管理和社会组织',
                19 => '国际组织',
                20 => '中介、外包',
                21 => '租赁和商户服务业'
            ],
            'liabilities' => [      //负债
                1 => '无负债',
                2 => '0-3000',
                3 => '3000-8000',
                4 => '8000-15000',    
                5 => '15000以上'
            ],
            'accumulation' => [     //公积金
                1 => '有公积金',
                2 => '没有公积金'
            ],
            "jobtime" => [          //在职时间
                1 => '0-5个月',
                2 => '6-11个月',
                3 => '1-3年',
                4 => '3-7年',
                5 => '7年以上'
            ],
            'company_type' => [     //单位类型
                1 => '外资企业',
                2 => '机关事业单位',
                3 => '国有企业',
                4 => '私营企业'
            ],
            'residence_info' => [  //住宅情况
                1 => '亲属楼宇',
                2 => '自置无按揭',
                3 => '自置有按揭',
                4 => '租房',
                5 => '集体宿舍',
                6 => '其他'
            ],
            "post_level" => [      //职务级别
                1 => '一般管理人员',
                2 => '一般干部',
                3 => '科员',
                4 => '一般员工',
                5 => '私营业主',
                6 => '一般主管/团队长',
                7 => '其他'
            ],
            'income_source' => [    //收入类型
                1 => '工资奖金',
                2 => '经营收入',
                3 => '投资理财',
                4 => '房租收入',
                5 => '其他收入'
            ],
            'social_security' => [  //社保
                1 => '有社保',
                2 => '无社保'
            ]
        ];

        return $config;
        
       
    }
     
}

//假数据
if (!function_exists("getFakeCash")) {
    function getFakeCash()
    {
        $data = [
            ['陶**',10],
            ['云**',5],
            ['钱**',10],
            ['尤**',8],
            ['葛**',5],
            ['蒋**',10],
            ['周**',15],
            ['诸**',2],
            ['许**',12],    
            ['张**',2],
            ['李**',10],
            ['何**',1]
        ];
        return $data;  
    }
}

//问题分类

if (!function_exists("questionConfig")) {
    function questionConfig()
    {
        $data = [
            1 => ['label'=>'贷款相关','value'=>1],
            2 => ['label'=>'功能相关','value'=>2]
        ];

        return $data;
    }
}

//产品搜索配置

if (!function_exists("productSeach")) {
    function productSeach()
    {
        $config = [
            "quotaType" => [ 
                1 => ['label'=>'0-3千',"value" => ['between',[0,3000]]],
                2 => ['label'=>'3千-5千',"value" => ['between',[3000,5000]]],
                3 => ['label'=>'5千-1万',"value" => ['between',[5000,10000]]],
                4 => ['label'=>'1万-3万',"value" => ['between',[10000,30000]]],
                5 => ['label'=>'3万-5万',"value" => ['between',[30000,50000]]],
                6 => ['label'=>'5万以上',"value" => ['>',50000]]
            ],
            'termType' => [
                1 => ['label'=>'0-1个月',"value" => ['between',[0,1]]],
                2 => ['label'=>'1-3个月',"value" => ['between',[1,3]]],
                3 => ['label'=>'3-6个月',"value" => ['between',[3,6]]],
                4 => ['label'=>'6-12个月',"value" => ['between',[6,12]]],
                5 => ['label'=>'12-36个月',"value" => ['between',[12,36]]],
                6 => ['label'=>'36个月以上',"value" => ['>',36]]
            ]

        ];
        return $config;
    }
}


if (!function_exists("configAuth")) {
    function configAuth () {
        $data = [
            "app_url"=>"https://rdd.vipwm.cn"
        ];
        return $data;
    }
}